import React from "react";
// 创建Context得到两个组件；
const { Provider, Consumer } = React.createContext();

class App extends React.Component {
    render() {
        return (
            <Provider value="pink">
                <div className="App">
                    <Children></Children>
                </div>
            </Provider>
        )
    }
}

class Children extends React.Component {
    render() {
        return (
            <div>
                子元素中
                <Consumer>
                    {
                        data=><span>父元素的值：{data}</span>
                    }
                </Consumer>
            </div>
        )
    }
}

export default App